package storage

import (
	"fmt"
	"io/fs"
	"io/ioutil"
	"os"
)

var files []File

type File struct {
	FileInfo fs.FileInfo
	FilePath string
}

func Files(path string) []File {
	dir, _ := ioutil.ReadDir(path)

	pathSep := string(os.PathSeparator)

	for _, file := range dir {
		if file.IsDir() {
			dirPath := fmt.Sprintf("%s%s%s", path, pathSep, file.Name())
			Files(dirPath)
		} else {
			object := File{
				FileInfo: file,
				FilePath: fmt.Sprintf("%s%s%s", path, pathSep, file.Name()),
			}
			files = append(files, object)
		}
	}

	return files
}
